package tony.core.codec

import com.fasterxml.jackson.annotation.JsonCreator
import tony.core.enums.StringEnumValue
import tony.core.enums.getEnum

/**
 * 二进制编码
 * @author tangli
 * @date 2023/09/12 19:45
 */
public enum class Encoding(
    override val value: String,
    private val codec: Codec,
) : StringEnumValue,
    Codec by codec {
    BASE64("BASE64", Base64Codec),
    HEX("HEX", HexCodec),
    ;

    @Suppress("ClassName")
    public companion object `-Companion` {
        @JsonCreator
        @JvmStatic
        public fun create(value: String): Encoding? =
            Encoding::class.java.getEnum(value)
    }
}
